package com.suxiaoxiao.springbootlearn.designpattern.iteratorpattern;

import com.suxiaoxiao.springbootlearn.designpattern.iteratorpattern.component.Menu;
import com.suxiaoxiao.springbootlearn.designpattern.iteratorpattern.component.MenuComponent;
import com.suxiaoxiao.springbootlearn.designpattern.iteratorpattern.component.MenuItem;
import com.suxiaoxiao.springbootlearn.designpattern.iteratorpattern.menu.impl.CafeMenu;
import com.suxiaoxiao.springbootlearn.designpattern.iteratorpattern.menu.impl.DinerMenu;
import com.suxiaoxiao.springbootlearn.designpattern.iteratorpattern.menu.impl.PancakeHouseMenu;
import org.junit.Test;

public class MenuTestDrive {

    @Test
    public void test_iterator_pattern() {
        PancakeHouseMenu pancakeHouseMenu = new PancakeHouseMenu();
        DinerMenu dinerMenu = new DinerMenu();
        CafeMenu cafeMenu = new CafeMenu();

        Waitress waitress = new Waitress(pancakeHouseMenu, dinerMenu, cafeMenu);
        waitress.printMenu();
    }

    @Test
    public void test_composition_pattern() {
        MenuComponent pancakeHouseMenu = new Menu("PANCAKE HOUSE MENU", "Breakfast");
        MenuComponent dinerMenu = new Menu("DINER MENU", "Lunch");
        MenuComponent cafeMenu = new Menu("CAFE MENU", "Dinner");
        MenuComponent dessertMenu = new Menu("DESSERT MENU", "Dessert of course!");

        MenuComponent allMenus = new Menu("ALL MENUS", "All menus combined");

        allMenus.add(pancakeHouseMenu);
        allMenus.add(dinerMenu);
        allMenus.add(cafeMenu);

        dinerMenu.add(new MenuItem(
                "Pasta",
                "Spaghetti with Marinara Sauce, and a slice of sourdough bread",
                true,
                3.89));

        dinerMenu.add(dessertMenu);

        dessertMenu.add(new MenuItem(
                "Apple Pie",
                "Apple pie with a flakey crust, topped with vanilla ice cream",
                true,
                1.59));

        com.suxiaoxiao.springbootlearn.designpattern.iteratorpattern.component.Waitress waitress =
                new com.suxiaoxiao.springbootlearn.designpattern.iteratorpattern.component.Waitress(allMenus);

        waitress.printMenu();

    }

}
